var carousel={
	delay:100,
	intervalID:-1,
	increment:5.1,
	goFront:true,
	direction:{
		vertical:{
			coordinate:"offsetTop",
			size:"offsetHeight",
			scroll:"scrollTop",
			wholeScroll:"scrollHeight"},
		horizontal:{
			coordinate:"offsetLeft",
			size:"offsetWidth",
			scroll:"scrollLeft",
			wholeScroll:"scrollWidth"}
	},
	defaultDirection:"vertical",
	prev:function(a,e){
		this.run(a,false);
	},
	next:function(a,e){
		this.run(a,true);
	},
	run:function(a,goFront){
		var base=a.parentNode.parentNode;
		if(!base.region){
			base.region=base.getElementsByTagName("dl")[0].parentNode;
		}
		base.dirDefinition = this.direction[ ( base.getAttribute("direction")||this.defaultDirection) ];
		base.region.scrollTarget = base.region[base.dirDefinition.scroll];
		function f(base){
			var o=arguments.callee;
			o.run.apply(o.scope,o.args);
		}
		f.scope = this;
		f.run = !goFront ? this.toBack : this.toFront;
		f.args = [base];
		if(this.intervalID){
			this.kill();
		}
		this.intervalID = window.setInterval(f,this.delay);
	},
	toFront:function(base){
		var r=base.region, d=base.dirDefinition, t=0;
		if((t=r.scrollTarget+r[d.size]) > r[d.wholeScroll] - r[d.size]){
			t=r[d.wholeScroll] - r[d.size];
		}
		r[d.scroll] += (t - r[d.scroll]) / this.increment;
		if(r[d.scroll] >= t){
			this.kill();
		}
	},
	toBack:function(base){
		var r=base.region, d=base.dirDefinition, t=r.target+r[d.size];
		if((t=r.scrollTarget-r[d.size]) < 0){t=0;}
		r[d.scroll] += (t - r[d.scroll]) / this.increment;
		if(r[d.scroll] <= t){
			this.kill();
		}
	},
	kill:function(){
		window.clearInterval(this.intervalID);
	},
	toString:function(){
		return "Carousel";
	}
}
